/**
 * @file
 * @brief 中断向量表
 * @author
 * + 隐星魂 (Roy Sun) <xwos@xwos.tech>
 * @copyright
 * + Copyright © 2015 xwos.tech, All Rights Reserved.
 * > Licensed under the Apache License, Version 2.0 (the "License");
 * > you may not use this file except in compliance with the License.
 * > You may obtain a copy of the License at
 * >
 * >         http://www.apache.org/licenses/LICENSE-2.0
 * >
 * > Unless required by applicable law or agreed to in writing, software
 * > distributed under the License is distributed on an "AS IS" BASIS,
 * > WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * > See the License for the specific language governing permissions and
 * > limitations under the License.
 */

#include <xwos/standard.h>
#include <xwos/osal/irq.h>
#include <xwos/ospl/syshwt.h>
#include <xwos/ospl/skd.h>
#include <SKEAZ1284.h>

#if (SOCCFG_IRQ_NUM < 8) || (SOCCFG_IRQ_NUM > 240)
#  error "SOCCFG_IRQ_NUM must be between 8 and 240 inclusive"
#endif

void SOC_NOOP_IRQHandler(void)
{
        while (true) {
        }
}

extern xwu8_t armv6m_isr_stack_top[];
void Reserved16_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void Reserved17_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void Reserved18_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void Reserved19_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void Reserved20_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void FTMRE_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void LVD_LLW_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void IRQ_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void I2C0_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void I2C1_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void SPI0_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void SPI1_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void UART0_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void UART1_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void UART2_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void ADC0_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void ACMP0_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void FTM0_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void FTM1_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void FTM2_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void RTC_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void ACMP1_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void PIT_CH0_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void PIT_CH1_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void KBI0_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void KBI1_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void Reserved42_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void ICS_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void WDOG_EWM_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void PWT_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void MSCAN_RX_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");
void MSCAN_TX_IRQHandler(void) __xwcc_weakalias("SOC_NOOP_IRQHandler");


struct soc_ivt {
        xwisr_f exc[SOCCFG_EXC_NUM];
        xwisr_f irq[SOCCFG_IRQ_NUM];
};

/**
 * @brief 中断向量表
 */
__xwcc_section(".armv6m.ivt") struct soc_ivt kea_ivt = {
        .exc = {
                (xwisr_f)armv6m_isr_stack_top,
                (xwisr_f)arch_isr_reset,
                arch_isr_nmi,
                arch_isr_hardfault,
                arch_isr_mm,
                arch_isr_busfault,
                arch_isr_usagefault,
                arch_isr_noop,
                arch_isr_noop,
                arch_isr_noop,
                arch_isr_noop,
                (xwisr_f)arch_isr_svc,
                arch_isr_dbgmon,
                arch_isr_noop,
                xwospl_skd_isr_swcx,
                xwospl_syshwt_isr,
        },
        .irq = {
                [Reserved16_IRQn] = Reserved16_IRQHandler,
                [Reserved17_IRQn] = Reserved17_IRQHandler,
                [Reserved18_IRQn] = Reserved18_IRQHandler,
                [Reserved19_IRQn] = Reserved19_IRQHandler,
                [Reserved20_IRQn] = Reserved20_IRQHandler,
                [FTMRE_IRQn] = FTMRE_IRQHandler,
                [LVD_LLW_IRQn] = LVD_LLW_IRQHandler,
                [IRQ_IRQn] = IRQ_IRQHandler,
                [I2C0_IRQn] = I2C0_IRQHandler,
                [I2C1_IRQn] = I2C1_IRQHandler,
                [SPI0_IRQn] = SPI0_IRQHandler,
                [SPI1_IRQn] = SPI1_IRQHandler,
                [UART0_IRQn] = UART0_IRQHandler,
                [UART1_IRQn] = UART1_IRQHandler,
                [UART2_IRQn] = UART2_IRQHandler,
                [ADC0_IRQn] = ADC0_IRQHandler,
                [ACMP0_IRQn] = ACMP0_IRQHandler,
                [FTM0_IRQn] = FTM0_IRQHandler,
                [FTM1_IRQn] = FTM1_IRQHandler,
                [FTM2_IRQn] = FTM2_IRQHandler,
                [RTC_IRQn] = RTC_IRQHandler,
                [ACMP1_IRQn] = ACMP1_IRQHandler,
                [PIT_CH0_IRQn] = PIT_CH0_IRQHandler,
                [PIT_CH1_IRQn] = PIT_CH1_IRQHandler,
                [KBI0_IRQn] = KBI0_IRQHandler,
                [KBI1_IRQn] = KBI1_IRQHandler,
                [Reserved42_IRQn] = Reserved42_IRQHandler,
                [ICS_IRQn] = ICS_IRQHandler,
                [WDOG_EWM_IRQn] = WDOG_EWM_IRQHandler,
                [PWT_IRQn] = PWT_IRQHandler,
                [MSCAN_RX_IRQn] = MSCAN_RX_IRQHandler,
                [MSCAN_TX_IRQn] = MSCAN_TX_IRQHandler,
        },
};
